package com.pan.controller.Managers;

import com.pan.aop.BusinessType;
import com.pan.aop.MyLog;
import com.pan.controller.tools.Methods;
import com.pan.controller.tools.R1;
import com.pan.service.IManagerService;
import com.pan.service.IUserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/managers")
@Tag(name = "ManagerController",description = "管理员逻辑删除")
public class ManagerController {
    @Autowired
    private IManagerService managerService;
    @Autowired
    private IUserService userService;

    Methods methods = new Methods();

    //管理员执行逻辑删除
    @Operation(summary = "管理员逻辑删除",description = "'1'为未删除 '0'为已删除")
    @PutMapping
    @MyLog(title = "管理员逻辑删除",optParam = "#{id}",businessType = BusinessType.DELETE)
    public R1 Logicdelete(@Parameter(description = "编号",required = true,example = "1")@RequestParam Integer id,
                          HttpServletRequest request){
        //检查用户权限
        if (methods.isManager(request,userService)){
            return new R1(managerService.LogicDelete(id));
        }
        return new R1(false,"权限不足");
    }




}
